// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import Global from './components/Global'
import 'babel-polyfill'
import axios from 'axios';
import qs from 'qs';
//const $cookies = require('vue-cookies');
import $cookies from 'vue-cookies';
Vue.use($cookies);

import './assets/font/iconfont.css';
import './css/main.css';
import './css/positionModel.css';
import './css/positionModeStatel.less';

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './JavaScript/directives'

Vue.prototype.GLOBAL = Global;
Vue.prototype.$qs = qs;
Vue.prototype.$axios = axios;
Vue.use(VueResource);
Vue.use(iView);
Vue.use(ElementUI);
//Vue.use(Global);
router.beforeEach((to, from, next) => {
 // var self=this;
 Global.addconfig().then(function (data) {
  //alert(data.addressUrl);
  Global.addressUrl = data.addressUrl;
  Global.layerTypeTreeUrl = data.layerTypeTreeUrl;
  Global.attachUrl = data.attachUrl;
  Global.historyLayer = data.historyLayer;
  Global.layerData = data.layerData;
  Global.loginUrl = data.loginUrl;
  Global.mapWkid = data.mapWkid;
  Global.mapZoom = data.mapZoom;
  Global.x = data.x;
  Global.y = data.y;
  Global.themeColor = data.themeColor;
  if (to.matched.some(record => record.meta.requiresAuth)) {
    if (to.path === '/login2') { next() }
    else {     //进入的不是登录路由
      console.log($cookies.get("status"));
     if ($cookies.get("status") != "logined") {
        next({ path: '/login2' })

      }
      else { 
        next()
      }

    }
  } else {
    next()
  }
})
  
})
new Vue({
  el: '#app',
  router,
  render: h => h(App)
  /*  components: { App },
   template: '<App/>' */
})
